//
// Created by Administrator on 2023/11/22.
//
#include<bits/stdc++.h>

using namespace std;

stack<int> num;
stack<char> op;

void eval() {

    int b = num.top();
    num.pop();//先出的为后操作数
    int a = num.top();
    num.pop();
    char c = op.top();
    op.pop();

    int x;
    if (c == '+') x = a + b;
    else if (c == '-') x = a - b;
    else if (c == '*') x = a * b;
    else x = a / b;
    num.push(x);
}

int main() {
    string s;
    cin >> s;

    unordered_map<char, int> pr{{'+', 1},
                                {'-', 1},
                                {'*', 2},
                                {'/', 2}};

    for (int i = 0; i < s.size(); ++i) {
        auto c = s[i];

        if (isdigit(c)) {
            int x = 0, j = i;
            //因为每次只读一位，所以遇到连续的数字需要转换一下
            while (j < s.size() && isdigit(s[j])) x = x * 10 + (s[j++] - '0');
            i = j - 1;//将i推进（注意j多加了一位）
            num.push(x);
        } else if (c == '(') op.push(c);
        else if (c == ')') {
            while (op.top() != '(')eval();
            op.pop();
        } else {
            while (!op.empty() && pr[c] <= pr[op.top()])eval();
            op.push(c);
        }

    }
    while (!op.empty()) eval();
    cout << num.top() << endl;
}